/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package skin;

import bean.LogueoBean;
import javax.ejb.EJB;
import javax.faces.context.FacesContext;
import javax.faces.event.ValueChangeEvent;
import negocio.GestorUsuarioLocal;

/**
 *
 * @author Ing. Monica Merlo, Ing. Agustin  Fernandez
 */
public class SkinBean {

    @EJB(beanName = "GestorUsuarioBean")
    private GestorUsuarioLocal gestorUsuarioBean;
    private String skin;

    public String getSkin() {
        return this.skin;
    }

    public void actualizarSkinSeleccionado(ValueChangeEvent e) {
        String skinSel = (String)e.getNewValue();
        this.setSkin(skinSel);
        FacesContext context = FacesContext.getCurrentInstance();
        LogueoBean logueoBean = (LogueoBean) context.getELContext().getELResolver().getValue(context.getELContext(), null, "LogueoBean");
        boolean resp = gestorUsuarioBean.modificarSkinSeleccionado(logueoBean.getUsuario(), skinSel);
        if(!resp){
            this.setSkin(getSkin());
        }
    }

    public void setSkin(String skin) {
        this.skin = skin;
    }
}
